package com.twu.biblioteca;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;

public class Password {
    private String encrypted;

    public Password(String unencrypted) {
        this.encrypted = Hashing.sha1().hashString(unencrypted, Charsets.UTF_8).toString();
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) return true;
        if (this.getClass() != other.getClass()) return false;

        Password password = (Password) other;
        return this.encrypted.equals(password.encrypted);
    }

    @Override
    public String toString() {
        return this.encrypted;
    }
}
